var e = getApp();

Component({
    addGlobalClass: !0,
    properties: {
        showFrom: {
            type: Boolean,
            default: !1
        }
    },
    pageLifetimes: {
        show: function() {}
    },
    observers: {
        showFrom: function(e) {
            1 == e && (this._getexplain(), this._getMember());
        }
    },
    data: {
        form: {
            member_name: "",
            member_card: ""
        },
        explain_title: "",
        explain_content: "",
        show1: !1
    },
    methods: {
        closePopup: function() {
            this.triggerEvent("confirm", !1);
        },
        _getexplain: function() {
            var t = this, a = e.getNetAddresss("from.div-from.explain");
            e._getNetWork({
                url: a,
                success: function(e) {
                    var a = e.data;
                    1 == a.result ? t.setData({
                        explain_title: a.data.explain_title,
                        explain_content: a.data.explain_content
                    }) : wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        },
        _getMember: function() {
            var t = this, a = e.getNetAddresss("from.div-from.getMemberInfo");
            e._getNetWork({
                url: a,
                success: function(e) {
                    var a = e.data;
                    1 == a.result ? t.setData({
                        "form.member_name": a.data.realname,
                        "form.member_card": a.data.idcard
                    }) : wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        },
        memberNameinp: function(e) {
            var t = e.detail.value;
            this.setData({
                "form.member_name": t
            });
        },
        membercardinp: function(e) {
            var t = e.detail.value;
            this.setData({
                "form.member_card": t
            });
        },
        saveInfo: function() {
            var t = this;
            if (e._isTextEmpty(this.data.form.member_name)) wx.showToast({
                title: "请填写姓名！",
                icon: "none"
            }); else if (e._isTextEmpty(this.data.form.member_card)) wx.showToast({
                title: "请填写身份证号！",
                icon: "none"
            }); else {
                var a = e.getNetAddresss("from.div-from.updateMemberInfo");
                a += "&member_name=" + this.data.form.member_name, a += "&member_card=" + this.data.form.member_card, 
                e._getNetWork({
                    url: a,
                    success: function(e) {
                        var a = e.data;
                        if (1 == a.result) {
                            var o = {
                                name: t.data.form.member_name,
                                card: t.data.form.member_card,
                                status: !1
                            };
                            t.triggerEvent("confirm", o);
                        } else wx.showToast({
                            icon: "none",
                            title: a.msg,
                            duration: 1500
                        });
                    },
                    fail: function(e) {
                        console.log(e);
                    }
                });
            }
        }
    }
});